package com.bite.lesson4;

import java.util.Scanner;

public class Demo_06 {
    static int ret = 0;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int n = scanner.nextInt();
            int count = Htower(n,'A','B','C');
            System.out.println(count);
        }
    }

    private static int Htower(int n, char pos1, char pos2, char pos3) {
        ret++;
        if (n == 1) {
            move(pos1,pos3);
            return 1;
        }
        Htower(n - 1, pos1, pos3, pos2);
        move(pos1,pos3);
        Htower(n - 1,pos2, pos1, pos3);
        return ret;
    }

    private static void move(char pos1 , char pos2) {
        System.out.print(pos1 + " -> " + pos2 + "  ");
    }

}
